package com.szkjt.action;

import java.io.IOException;

import org.activiti.engine.RuntimeService;
import org.activiti.engine.TaskService;
import org.activiti.engine.task.Task;

import net.sf.json.JSONObject;

import com.szkjt.model.Arrangement;
import com.szkjt.model.Finance;
import com.szkjt.service.ArrangementService;
import com.szkjt.service.BaseService;
import com.szkjt.service.FinanceService;

public class ArrangementAction extends BaseAction<Arrangement> {

	private ArrangementService arrangementService;
	private FinanceService financeService;
	
	private TaskService taskService;
	
	public void associate() {
		Finance finance = financeService.getById(1);
		Arrangement arrangement = arrangementService.getById(1);
		
		String processId = finance.getProcessId();
		Task task = taskService.createTaskQuery().processDefinitionKey(processId).singleResult();
		
		taskService.complete(task.getId());
		
		arrangement.getListFinance().add(finance);
		arrangementService.saveOrUpdate(arrangement);
	}
	
	@Override
	protected BaseService<Arrangement> getBaseService() {
		return arrangementService;
	}

	@Override
	protected JSONObject getJSONObject(Arrangement m) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected Arrangement getModel() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected boolean validateModel() throws IOException {
		// TODO Auto-generated method stub
		return false;
	}

	//------
	public ArrangementService getArrangementService() {
		return arrangementService;
	}

	public void setArrangementService(ArrangementService arrangementService) {
		this.arrangementService = arrangementService;
	}

	public FinanceService getFinanceService() {
		return financeService;
	}

	public void setFinanceService(FinanceService financeService) {
		this.financeService = financeService;
	}

	public TaskService getTaskService() {
		return taskService;
	}

	public void setTaskService(TaskService taskService) {
		this.taskService = taskService;
	}

}
